﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Newtonsoft.Json;

[JsonObject]
public class LoginEntity
{
    public LoginEntity() { LoginStatus = LoginStatusEnum.Waiting; }

    public string Account { get; set; }
    public string Password { get; set; }
    public string ServerNo { get; set; }
    public string Sign { get; set; }
    public string ServerIP { get; set; }
    public int Port { get; set; }
    public string TicketTime { get; set; }
    public LoginStatusEnum LoginStatus { get; set; }
    public LoginResultEnum LoginResult { get; set; }
    public DateTime? CompletedTime { get; set; }
    public DateTime? RegisterTime { get; set; }
    public DateTime? StartTime { get; set; }

    public CookieContainer CookieContainer { get; set; }
    public List<Cookie> Cookies { get; set; }

    public override bool Equals(object obj)
    {
        LoginEntity lg = obj as LoginEntity;
        if (lg == null) { return false; }
        return lg.Account == this.Account && lg.ServerNo == this.ServerNo;
    }

    public override int GetHashCode()
    {
        return (this.Account + this.ServerNo).GetHashCode();
    }
}

public enum LoginStatusEnum
{
    Waiting,
    Logining,
    Completed
}

public enum LoginResultEnum
{
    Success,
    Failure,
    WrongPassword,
    TryTooManyTimes,
    NeedCode,
    UnkowError
}